package eu.news.servlet.admin.news;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import eu.news.data.hibernate.dao.HB_NewsDAO;
import eu.news.data.hibernate.pojo.HB_News;
import eu.news.index.NewsIndexDAO;

/**
 * Servlet implementation class ReIndex
 */
public class ReIndex extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ReIndex() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HB_NewsDAO dao=new HB_NewsDAO();
		for(HB_News news:dao.getAll(0, 100)){
			NewsIndexDAO.updateIndex(news);
		}
		response.setContentType("text/html; charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.getWriter().print("重建索引完毕，请小心保存索引文件夹，重建索引是一项巨大的开销。");
	}

}
